/*
 * @Author: xiaosihan
 * @Date: 2023-07-13 17:22:53
 * @Last Modified by: xiaosihan
 * @Last Modified time: 2024-10-03 11:37:25
 */

import { GoodsData } from '#/type';
import utils from '@/utils/utils';
import { observable, configure } from 'mobx';

configure({ enforceActions: 'never' });

// 初始商品数据
const initGoodsData: GoodsData = {
  id: 0,
  disable: 1,
  sku: '',
  spu: '',
  name: '',
  sort: 0,
  thumbs: [],
  modelUrl: '',
  miniProgramModelUrl: '', // 这个模型是优化过并且没有压缩过的,微信小程序专用的
  mockupUrls: [],
  miniProgramMockupUrls: [], // 这个模型是优化过并且没有压缩过的,微信小程序专用的
  component: [],
  catalogueId: 0,
  createTime: 0,
  detail: '',
  isDel: false,
  productCode: '',
  sizePrice: [],
  suitFor: '',
  updateTime: '',
  size: [
    { enable: false, lock: false, name: '3XS', width: 1500, height: 1000, printLayout: {} },
    { enable: false, lock: false, name: '2XS', width: 1500, height: 1000, printLayout: {} },
    { enable: false, lock: false, name: 'XS', width: 1500, height: 1000, printLayout: {} },
    { enable: false, lock: false, name: 'S', width: 1500, height: 1000, printLayout: {} },
    { enable: false, lock: false, name: 'M', width: 1500, height: 1000, printLayout: {} },
    { enable: false, lock: false, name: 'L', width: 1500, height: 1000, printLayout: {} },
    { enable: false, lock: false, name: 'XL', width: 1500, height: 1000, printLayout: {} },
    { enable: false, lock: false, name: '2XL', width: 1500, height: 1000, printLayout: {} },
    { enable: false, lock: false, name: '3XL', width: 1500, height: 1000, printLayout: {} },
    { enable: false, lock: false, name: '4XL', width: 1500, height: 1000, printLayout: {} },
    { enable: false, lock: false, name: '5XL', width: 1500, height: 1000, printLayout: {} },
    { enable: false, lock: false, name: '6XL', width: 1500, height: 1000, printLayout: {} },
  ],
  sizeInfo: { columns: [], dataSource: [] },
  modalSize: 'XS',
  price: 0, // 最小价格
  colors: [
    {
      color: '#ffffff',
      cn: '白色',
      en: '白色',
    },
  ], // 商品可选颜色
  weight: 1, // 商品
  supplier: '', // 供应商
  sex: '男士', // 性别
  materialName: '', // '面料, 牛奶丝, 鸟眼布,单面汗布,抓绒布,平版布,小方格,共网眼',
  material: '', // '面料材质, 100%棉, 100%涤纶,55%棉35%涤纶',
  frontPrintFee: 0, // 前面印刷费用
  backPrintFee: 0, //背面印刷费用
  technology: '', // 二次工艺名称
  fabricDoorWidth: '', // 面料门幅
  fabricWeight: '', // 面料克重
  fillType: 1, // 印刷方式 0,满版印刷, 1 局部印
  styleNumber: '', // 款号
};

const goodsEditorStore = observable({
  // 是否显示弹窗
  show: false,
  setShow(show: boolean) {
    this.show = show;
  },

  // 商品id
  goodsId: '',
  async setGoodsId(goodsId: string) {
    if (goodsId) {
      this.goodsId = goodsId;
      // const goodsDetail = await goodsService.getGoodsById(goodsId);
      // this.setGoodsDetail(goodsDetail);
    } else {
      this.setGoodsDetail(initGoodsData);
    }
  },

  // 商品详情
  goodsDetail: initGoodsData,
  setGoodsDetail(goodsDetail: any = initGoodsData) {
    this.goodsDetail = goodsDetail;
  },

  from: 0,
  setFrom(b: number) {
    this.from = b;
  },

});

export default goodsEditorStore;
